package priv.yiyuan.example.design.product.strategy;

/**
 * 折扣价格策略
 * <p>
 * 策略模式-具体策略
 */
public class DiscountPriceStrategy implements PriceCalculationStrategy {

    /**
     * 折扣率
     */
    private double discountRate;

    public DiscountPriceStrategy(double discountRate) {
        this.discountRate = discountRate;
    }

    @Override
    public double calculatePrice(double originalPrice) {
        System.out.println("使用折扣计算折扣价格, 折扣率: " + discountRate);
        return originalPrice * (1 - discountRate);
    }
}
